<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    <div class="container-div">
    	<div class="row">
	        <div class="col-sm-12 select-info order-table">
		        <table id="bootstrap-table" data-mobile-responsive="true">
		        </table>
	        </div>
	    </div>
    </div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var prefix = ctx + "module/parent"

        $(function() {
            var options = {
                url: prefix + "/list",
                modalName: "家长",
                search: false,
		        showExport: false,
                columns: [{
		            checkbox: true
		        },
		        {
		            title: '序号',
		            field: '',
		            align: 'center',
		            formatter: function (value, row, index) {
		                var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;     //通过table的#id 得到每页多少条
		                var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber; //通过table的#id 得到当前第几页
		                return pageSize * (pageNumber - 1) + index + 1;    // 返回每条的序号： 每页条数 *（当前页 - 1 ）+ 序号
		            }
		        },
				{
					field : 'studentNumber', 
					title : '学生学号' 
				},
				{
					field : 'name', 
					title : '家长名称' 
				},
				{
					field : 'appellation', 
					title : '称谓',
					formatter:function(value,row,index){
						return getAppellation(value);
					}
				},
				{
					field : 'telephone', 
					title : '联系电话' 
				},
				{
					field : 'openId', 
					title : '微信绑定',
					formatter: function(value, row, index) {
						if (value == '' || value == null) {
		                    return '<span class="badge badge-danger">否</span>';
		                } else {
		                    return '<span class="badge badge-primary">是</span>';
		                }
		            }
				}]
            };
            $.table.init(options);
        });
        
        function getAppellation(id){
        	var s = "";
        	switch (id){
        		case "1":
        			s = "父亲";
        			break;
        		case "2":
        			s = "母亲";
        			break;
        		case "3":
        			s = "爷爷";
        			break;
        		case "9":
        			s = "家长";
        			break;
        		default:
        			s = id;
        	}
        	return s;
        }
        
        
    </script>
</body>
</html>